package com.gnerv.rabbitmq.agent.command;

import com.gnerv.rabbitmq.agent.model.entity.Node;
import com.gnerv.rabbitmq.agent.tools.ExecTools;
import com.google.common.collect.Lists;

import java.util.List;

/**
 * @author Gnerv LiGen
 */
public class NodeCommand extends AbstractRabbitmqctlCommand {

    private NodeCommand(Node node){
        super();
        setNode(node);
    }

    public static NodeCommand build(Node node){
        return new NodeCommand(node);
    }

    public ExecTools.ExecResult start() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("start");
        return run(listQueues);
    }

    public ExecTools.ExecResult startApp() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("start_app");
        return run(listQueues);
    }

    public ExecTools.ExecResult stop() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("stop");
        return run(listQueues);
    }

    public ExecTools.ExecResult stopApp() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("stop_app");
        return run(listQueues);
    }

    public ExecTools.ExecResult reset() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("reset");
        return run(listQueues);
    }

    public ExecTools.ExecResult version() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("version");
        return run(listQueues);
    }

    public ExecTools.ExecResult status() {
        List<String> listQueues = Lists.newArrayList();
        listQueues.add("status");
        return run(listQueues);
    }

    public Node selectByName(String name){
        Node node = new Node();
        node.setName("rabbit@bogon");
        node.setPath("/Users/ligen/Software/RabbitMq/rabbitmq_server-3.7.9");
        return node;
    }

}
